package top.hcode.hoj.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import top.hcode.hoj.common.result.CommonResult;
import top.hcode.hoj.pojo.dto.BaseIdDTO;
import top.hcode.hoj.pojo.dto.QuerySampleDTO;
import top.hcode.hoj.pojo.entity.coll.CollHonorRecord;
import top.hcode.hoj.service.admin.AdminCollHonorRecordService;

/**
 * @author orangej
 * @since 2025-01-21
 */
@Slf4j
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class AdminCollHonorRecordController {

    private final AdminCollHonorRecordService collHonorRecordService;

    @GetMapping("/admin/coll-honor-record/list")
    public CommonResult<IPage<CollHonorRecord>> getCollHonorRecordList(QuerySampleDTO querySampleDTO) {
        return CommonResult.successResponse(collHonorRecordService.getCollHonorRecordList(querySampleDTO));
    }

    @PostMapping("/admin/coll-honor-record/save")
    public CommonResult<CollHonorRecord> saveCollHonorRecord(@RequestBody CollHonorRecord collHonorRecord) {
        return CommonResult.successResponse(collHonorRecordService.saveCollHonorRecord(collHonorRecord));
    }

    @PostMapping("/admin/coll-honor-record/delete")
    public CommonResult<Void> deleteCollHonorRecord(@RequestBody BaseIdDTO dto) {
        collHonorRecordService.deleteCollHonorRecord(dto.getId());
        return CommonResult.successResponse();
    }

}
